
// window.isCloseHint = true;
//// 初始化关闭
// window.addEventListener("onunload", function(e) {
//     if (window.isCloseHint) {
//
//         setCookie("at", "");
//         sessionStorage.setItem("token","")
//         return H_headRegis();
//     }
// });
// 监测关闭浏览器





var vm = new Vue(
    {
        el:"#app",
        data(){
            return{
                queryArray:[

                ],
                selectArray:[],
                keyWord:"",
                selectValue:"3",
                errorSoftName:false,
                isLogin:false,
                domain:window.location.href,
            }
        },
        created(){
            // if(getCookie("at") === ""){
            //     this.isLogin = true;
            // }else{
            // 	this.isLogin = false;
            // }
            if(sessionStorage.getItem("token") === null ||sessionStorage.getItem("token") === ""){
                this.isLogin = false
                console.log("不处于登录状态")
            }else{

                console.log("处于登录状态")
                console.log(sessionStorage.getItem("token"))
                this.isLogin = true;
            }
        },
        mounted(){

        },
        methods:{
            loginOut:function(){
                H_headRegis();
            },
            choose:function(index){
                let temp = {
                    "name":this.queryArray[index].softName,
                };
                this.selectArray.push(temp);
            },
            turnStatus:function(){
                this.errorSoftName = false;
            },
            deleteItem:function(index){
                this.selectArray.splice(index,1);
            },
            clearAll:function(){
                this.selectArray = [];
            },
            copyAll:function(){
                let url ="";
                for(let i = 0;i<this.selectArray.length;i++){
                    url+= (i+1)+"."+ String(this.selectArray[i].name)+"\n";
                }
                let onInput = document.createElement("textarea");
                onInput.value = url;
                document.body.appendChild(onInput);
                onInput.select();
                document.execCommand("Copy");
                onInput.remove();
                layui.use('layer', function(){
                    var layer = layui.layer;
                    layer.msg('内容已复制');
                });

            },
            copyLeft:function(){
                let url ="";
                for(let i = 0;i<this.queryArray.length;i++){
                    url+= (i+1)+"."+ String(this.queryArray[i].softName)+"\n";
                }
                let onInput = document.createElement("textarea");
                onInput.value = url;
                document.body.appendChild(onInput);
                onInput.select();
                document.execCommand("Copy");
                onInput.remove();
                layui.use('layer', function(){
                    var layer = layui.layer;
                    layer.msg('内容已复制');
                });
            },
            getValue:function(event,index){
                console.log(index);
                let tempValue = event.currentTarget.value;
                console.log(tempValue);
                this.selectArray[index].name = tempValue;
            },
            queryNameData:function(){
                if(this.keyWord == ""){
                    this.errorSoftName = true;
                    return;
                }
                let _this = this;
                let url = API_URL_PUBLIC + "biz/softname/listSoftName";
                let data = {
                    softName:_this.keyWord, //用户查询条件，软著名称
                    pageNo:"1", //当前页数（1）
                    pageSize:_this.selectValue,//选择的显示数量
                };
                var ajaxDfd = $.Deferred();

                apiService5(url,data,ajaxDfd);
                $.when(ajaxDfd).then(function(data) { //这里的参数为什么是data,因为在下面的ajax函数中,我把data当成resolve()的参数传过来了
                    if(data.result === 'true'){
                        if(data.data.list.length === 0){
                            layui.use('layer', function(){
                                let layer = layui.layer;
                                layer.open({
                                    title: '温馨提示',
                                    content: "您的关键词不存在，您可以拆开关键词，重新起名字。或者 扫描微信二维码联系客服，人工起名字！"+'<div style="width: 100%;"><img src="http://www.51hezuo.com.cn/img/code.png" style="display: block;margin:0 auto;"></div>',
                                });
                            });
                        }
                        _this.queryArray = data.data.list;


                    }else{
                        layui.use('layer', function(){
                            let layer = layui.layer;
                            layer.open({
                                title: '系统异常',
                                content: data.reason,
                            });
                        });
                    }


                }, function(xhr) { //这里的参数为什么是xhr,因为在下面的ajax函数中,我把xhr当成reject()的参数传过来了
                    errbox(JSON.stringify(e));
                });

            },
            selectChange:function(event){
                this.selectValue = event.target.value;
                console.log(this.selectValue)
            },

        },
    }
);
